home *** CD-ROM | disk | FTP | other *** search
/ s-gikan2.maizuru-ct.ac.jp / s-gikan2.maizuru-ct.ac.jp.zip / s-gikan2.maizuru-ct.ac.jp / pub / old / ncvc351d_install.exe / {app} / scripts / change_for_lathe.pl < prev    next >
Perl Script  |  2005-05-25  |  970b  |  57 lines

  1. #! /usr/bin/perl
  2.  
  3. #  ver.1.1
  4.  
  5. #  NCVCé┼ì∞ɼé╡é╜GâRü[âhé≡üANCÉ∙ö╒ùpé╔ò╧è╖é╖éΘâXâNâèâvâg #
  6.  
  7.  
  8. %XY= ("X","Z","Y","X","I","K","J","I");
  9.  
  10. $pre_file= $ARGV[0];
  11. $out_file= $ARGV[1];
  12. open(IN,$pre_file);
  13. open(OUT,">$out_file");
  14.  
  15. while(<IN>){
  16.     if(!/^N?[0-9\s]*[\(\%]/){
  17.         $_= change_XZYX($_);
  18.         $_= X_to_2X($_);
  19.         $_= G17_G18($_);
  20.     }
  21.     print OUT;
  22. }
  23.  
  24. close(OUT);
  25. close(IN);
  26.  
  27.  
  28. sub change_XZYX{
  29.     my ($line)= @_;
  30.     my $new_line;
  31.     while($line =~ /([XYIJ])([0-9\-\.]+)/){
  32.         $new_line= $new_line.$`.$XY{$1}.$2;
  33.         $line= $';
  34.     }
  35.     return $new_line.$line;
  36. }
  37.  
  38. sub X_to_2X{
  39.     my ($line)= @_;
  40.     my ($new_line,$pre_line,$num);
  41.     while($line =~ /X([\-\d\.]+)/){
  42.         ($pre_line,$num,$line)= ($`,$1,$');
  43.         $num= int($num*1000) * 2;
  44.         $num= $num / 1000;
  45.         if($num !~ /\./ and $num != 0){ $num = $num."\.";}
  46.         $new_line= $new_line.$pre_line."X".$num;
  47.     }
  48.     return $new_line.$line;
  49. }
  50.  
  51. sub G17_G18{
  52.     my ($line)= @_;
  53.     $line =~ s/G17/G18/;
  54.     return $line;
  55. }
  56.  
  57.